package com.jt.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor(){
//        创建一个分页插件
        PaginationInterceptor paginationInterceptor=new PaginationInterceptor();
//        设置请求的最大资源大于最大页后操作，true返回首页，false继续请求，默认false
//        paginationInterceptor.setOverflow(false);
//        设置最大单页限制数量，默认500条，-1不受限制
//        paginationInterceptor.setLimit(500);
//        开启count的join优化，针对部分left join
        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
        return  paginationInterceptor;
    }
}
